package com.zhuss.controller.product;

import com.zhuss.bean.bo.product.line.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import com.zhuss.common.BaseController;
import com.zhuss.common.OperateService;
import com.zhuss.product.line.LineOperateServiceExt;
import com.zhuss.exception.DzcxException;


/**
 * @description: 线路操作的Controller
 * @author: zhushanshuo
 * @create: Wed Dec 30 13:08:49 CST 2020
 **/
@RestController
@RequestMapping("/line")
public class LineOperateController extends BaseController {

	@Autowired
	@Qualifier("lineOperateService")
	private OperateService<Void, Object> lineOperateService;

	@Autowired
	@Qualifier("lineOperateServiceExt")
	private LineOperateServiceExt lineOperateServiceExt;

	/**
	 * 创建
	 * @param bo
	 * @throws DzcxException
	 */
	@ResponseBody
    @PostMapping("/create")
    public void create(@RequestBody CreateLineBo bo) throws DzcxException {

		lineOperateService.create(bo);
    }


	/**
	 * 根据线路绑定站点
	 * @param bo
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@RequestMapping("/bind")
	public void bind(@RequestBody BindLineBo bo) throws DzcxException {

		lineOperateServiceExt.bind(bo);
	}

	/**
	 * 修改
	 * @param bo
	 * @throws DzcxException
	 */
	@ResponseBody
    @PostMapping("/update")
    public void update(@RequestBody UpdateLineBo bo) throws DzcxException {

		lineOperateService.update(bo);
    }

	/**
	 * 删除
	 * @param bo
	 * @throws DzcxException
	 */
	@ResponseBody
    @PostMapping("/delete")
    public void delete(@RequestBody DeleteLineBo bo) throws DzcxException {

		lineOperateService.delete(bo);
    }

	/**
	 * 启用
	 * @param bo
	 * @throws DzcxException
	 */
	@ResponseBody
	@PostMapping("/start")
	public void start(@RequestBody StartLineBo bo) throws DzcxException {

		lineOperateServiceExt.start(bo);
	}

	/**
	 * 停用
	 * @param bo
	 * @throws DzcxException
	 */
	@ResponseBody
	@PostMapping("/stop")
	public void stop(@RequestBody StopLineBo bo) throws DzcxException {

		lineOperateServiceExt.stop(bo);
	}
	
	
	/**
	 * 激活、置为模板
	 * @param bo
	 * @throws DzcxException
	 */
	@ResponseBody
	@PostMapping("/enable")
	public void enable(@RequestBody EnableLineBo bo) throws DzcxException {

		lineOperateServiceExt.enable(bo);
	}


}
